﻿Imports System.Data
Imports System.Data.Odbc
Imports WSEntidades
Imports Utilerias
Imports Npgsql
Imports MySql.Data.MySqlClient
Public Class ClientesComFact
    Public Shared Function Build(ByVal dr As MySqlDataReader) As ClientesComBE
        Dim tmpClientesCom As ClientesComBE = New ClientesComBE()
        Try
            With tmpClientesCom
                .IdCli = convertDTFromDb.convertInt32(dr.Item("IdCli"))
                .LimiteCredito = convertDTFromDb.ConvertDecimal(dr.Item("LimCre"))
                .Saldo = convertDTFromDb.ConvertDecimal(dr.Item("Saldo"))
                .DiasCredito = convertDTFromDb.convertInt32(dr.Item("DiasCred"))
                If (dr.Item("IdMetodP") Is DBNull.Value) Then
                    .MetodoPago = Nothing
                Else
                    .MetodoPago = MetodospagFact.Build(dr)
                End If
                .Banco = convertDTFromDb.ConvertString(dr.Item("Banco"))
                .CuentaBancaria = convertDTFromDb.ConvertString(dr.Item("CuentaBan"))
                .ClienteMayoreo = convertDTFromDb.ConvertBoolean(dr.Item("CliMay"))
                .ListPrecios = convertDTFromDb.convertInt32(dr.Item("ListPrec"))
                .Descuento = convertDTFromDb.ConvertDecimal(dr.Item("Descuento"))
                .Clasificacion = convertDTFromDb.ConvertString(dr.Item("Clasificacion"))
                If (dr.Item("IdVendedor") Is DBNull.Value) Then
                    .Vendedor = Nothing
                Else
                    .Vendedor = VendedoresFact.buildInternal(dr.Item("IdVendedor"),
                                                             dr.Item("Clave"),
                                                             dr.Item("Nombre"),
                                                             dr.Item("Porc"),
                                                             dr.Item("vendStatus"))
                End If
                .CuentaContable = convertDTFromDb.ConvertString(dr.Item("CtaCont"))
                '.SubCuenta = convertDTFromDb.ConvertString(dr.Item("SubCta"))
                .CuentaAnticipos = convertDTFromDb.ConvertString(dr.Item("CtaAnt"))
            End With
            Return tmpClientesCom
        Catch ex As Exception
            Throw
        Finally
            tmpClientesCom = Nothing
        End Try
    End Function
End Class
